<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC>
<html>
<head>
<base href="<%=basePath%>">

<title>商品查询</title>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.js"></script>
<script type="text/javascript">
	$(function() {
		var userId ="<%=session.getAttribute("userId")%>"
			
		$("#publishCommodity").click(function(){
			if(userId != "null"){
				window.location="admin/editCommodity.jsp";			
			}if(userId == "null") {
				var result = confirm("您还未登录，即将跳转到登录界面")
				if(result){
					window.location="admin/userLogin.jsp";	
				};
			};
		});
		
		$("#loginOut").click(function(){
			if(userId == "null"){
				window.location="admin/userLogin.jsp";
			};
			if(userId != "null"){
				window.location="login/loginOut.do";
			};
		});
	})
	
	var socket =null;
$(function(){
	function parseObj(strData){//转换对象
	    return (new Function( "return " + strData ))();
	};
	//创建socket对象
	socket = new WebSocket("ws://" + window.location.host +
			"/${pageContext.request.contextPath}/talk/" + $("#userName").val());
			
	//连接创建后调用
	socket.onopen = function() {
		$("#showMsg").append("连接成功...<br/>");
	};
	
	//接收到服务器消息后调用
	socket.onmessage = function(message) {
		var result = confirm("你收到了一条新的信息，是否打开聊天室");
		if(result){
			window.open("http://localhost:8080/TradingPlatform/admin/chat.jsp");
		}
	};
	
	//关闭连接的时候调用
	socket.onclose = function(){
	};
	
	//出错时调用
	socket.onerror = function() {
	};
	
	$("#sendButton").click(function() {
	});
});
</script>

</head>

<body>
	<header> </header>
	<div class="person-info container">
		<span>欢迎: ${userName}</span> &nbsp&nbsp&nbsp<a
			href="javaScript:void(0)" id="loginOut">${userName!=null ? '退出' : '登录'}</a>
			<input type="hidden" value="${userName}" id="userName">
		<div class="person-info-show"></div>
	</div>
	<nav class=" navbar-default nav-extends" role="navigation">
		<div class="container" style="margin-top:25px;">
			<div class="container-fluid">
				<!-- Brand and toggle get grouped for better mobile display -->
				<div class="navbar-header">
					<button type="button" class="navbar-toggle collapsed"
						data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
						<span class="sr-only">Toggle navigation</span> <span
							class="icon-bar"></span> <span class="icon-bar"></span> <span
							class="icon-bar"></span>
					</button>
					<a class="brand" href="inquiry/all.do">科大二手交易平台</a>
				</div>

				<!-- Collect the nav links, forms, and other content for toggling -->
				<div class="collapse navbar-collapse "
					id="bs-example-navbar-collapse-1">
					<ul class="nav navbar-nav">
						<li class=""><a href="inquiry/all.do">首页</a></li>
						<li style="border-left:1px solid #CCCCCC;"><a
							href="http://s.ershou.taobao.com/">Link</a></li>
						<li style="border-left:1px solid #CCCCCC;"><a
							href="javaScript:void(0)" id="publishCommodity">发布闲置</a></li>
						<li style="border-left:1px solid #CCCCCC;"><a
							href="userInfo/searchProduct.do" id="publishCommodity">我的二手</a></li>
					</ul>
					<form class="navbar-form navbar-right" role="search"
						action="inquiry/search.do" method="post">
						<div class="form-group">
							<input type="text" class="form-control" placeholder="输入商品名，或@用户名"
								name="searchInput" value="${searchInput}">
						</div>
						<button type="submit" class="btn btn-default ">
							查询 <span class="glyphicon glyphicon-search"></span>
						</button>
					</form>
				</div>
				<!-- /.navbar-collapse -->
			</div>
			<!-- /.container-fluid -->
		</div>
	</nav>

	<section class="main-section">
		<h3>个人闲置:</h3>
		<div class="classify">
			<ul>
				<li><a href="inquiry/type/11101.do">数码|电脑</a></li>
				<li><a href="inquiry/type/11102.do">数码|相机</a></li>
				<li><a href="inquiry/type/11103.do">数码|配件</a></li>
				<li><a href="inquiry/type/22201.do">服饰|上衣</a></li>
				<li><a href="inquiry/type/22202.do">服饰|裤</a></li>
				<li><a href="inquiry/type/22203.do">服饰|鞋</a></li>
				<li><a href="inquiry/type/33301.do">音像|dvd光碟</a></li>
				<li><a href="inquiry/type/33302.do">书籍|考研书籍</a></li>
				<li><a href="inquiry/type/33303.do">文体|球类</a></li>
				<li><a href="inquiry/type/44401.do">其他|其他</a></li>
			</ul>
		</div>
		<!--classify end-->
		<div class="search-bar"></div>
		<!--search-bar end-->
		<div class="pic-show">

			<!--boxone-->

			<c:forEach var="product" varStatus="status" items="${productList}">
				<div class="box">
					<div class="pic-box">
						<header class="pic-box-header">
							<img src="${product.userAvatar }" alt=""> <a
								href="inquiry/user/${product.userName}.do">${product.userName }</a>
						</header>
						<section class="pic-box-body">
							<a href="detail/info/${product.productId}.do"><img
								src="${product.imageName }" alt=""></a> <span
								class="pic-box-body-icon">&yen;:</span> <span
								class="pic-box-body-worth">${ product.currentPrice eq null ? '你来定' : product.currentPrice }</span>
							<hr />
							<p class="pic-box-body-p">${product.productName}</p>
						</section>
						<footer class="pic-box-footer">
							<a href="javaScript:void(0)">留言<span>10</span></a>
						</footer>
					</div>
				</div>
			</c:forEach>

		</div>

	</section>

	<footer class="main-footer"> </footer>
</body>
</html>
